#include <gtest/gtest.h>
#include <thread>
#include "scheduler/parallel_scheduler.h"
#include "../sample/navigation_task.h"
#include "../sample/battery_level_check.h"
#include "scheduler/scheduler_factory.h"

TEST(test_parallel_scheduler_demo, test_parallel_scheduler)
{
    auto navigation_task = task::TaskFactory<NavigationTask>::createTask("navigation_task");
    auto battery_level_check = task::TaskFactory<BatteryLevelCheck>::createTask("battery_level_check");

    auto parallel_scheduler = scheduler::SchedulerFactory<scheduler::ParallelScheduler>::createScheduler("object_search_scheduler");
    parallel_scheduler->appendTask(navigation_task);
    parallel_scheduler->appendTask(battery_level_check);

    std::thread([&parallel_scheduler]
                {
                    sleep(10);
                    parallel_scheduler->pause();
                    sleep(5);
                    parallel_scheduler->resume();
                    sleep(5);
                    parallel_scheduler->cancel();
                }).detach();
    parallel_scheduler->run();

    EASE_INFO("done");
}
